package bsf.baseservice.businessmq.dal;


import bsf.baseservice.businessmq.model.tb_config_model;
import bsf.db.DbConn;
import bsf.util.ConvertUtil;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class tb_config_dal
{
	public ArrayList<tb_config_model> list(DbConn PubConn)
	{
		StringBuilder stringSql = new StringBuilder();
		stringSql.append("select s.* from tb_config s WITH(NOLOCK)");
		List<Map<String, Object>> ds = PubConn.executeList(stringSql.toString(),new Object[]{});
		java.util.ArrayList<tb_config_model> rs = new java.util.ArrayList<tb_config_model>();
		if (ds!=null && ds.size()>0)
		{
			for (Map<String, Object> dr : ds)
			{
				rs.add(createModel(dr));
			}
		}
		return rs;
	}

	public String get2(DbConn PubConn, String key)
	{;
		StringBuilder stringSql = new StringBuilder();
		stringSql.append("select value from tb_config s WITH(NOLOCK) where s.[key]=?");
		List<Map<String, Object>> ds = PubConn.executeList(stringSql.toString(), new Object[]{key});
		if (ds != null && ds.size() > 0)
		{
			return String.valueOf(ds.get(0));
		}
		return null;
	}

	public tb_config_model createModel(Map<String, Object> dr)
	{
		tb_config_model o = new tb_config_model();

		//����Key
		if (dr.containsKey("key"))
		{
			o.key= ConvertUtil.nullToStr(dr.get("key"));
		}
		//����Value
		if (dr.containsKey("value"))
		{
			o.value= ConvertUtil.nullToStr(dr.get("value"));
		}
		//���ñ�ע��Ϣ
		if (dr.containsKey("remark"))
		{
			o.remark=ConvertUtil.nullToStr(dr.get("remark"));
		}
		return o;
	}
}